<template>
  <div class="exhibits-content" :style="{ width: props.info.width + 'rem', height: props.info.height + 'rem' }">
    <div class="list">
      <div
        class="item-parent"
        :class="{ 'n-mg': index === 0 }"
        v-for="(item, index) in props.info.showpieceList"
        :key="index"
      >
        <div
          :class="{
            'exhibits-item1': (index) % 2 === 0,
            'exhibits-item2': (index) % 2 !== 0,
          }"
          @contextmenu.stop="emit('onContextMenuChild', $event, index)"
          :style="{
            'background-image': `url(${
              publicUrls +
              ((index) % 2 === 0
                ? 'free/style3/displayBoardStyle4Bg1.webp'
                : 'free/style3/displayBoardStyle4Bg2.webp')
            })`,
          }"
          class="exhibits-item border-hover-style"
        >
          <p class="items-title" v-if="(index ) % 2 === 0">
            {{ item.name }}
          </p>
          <div class="cover-box">
            <img
              class="cover"
              v-lazy="getLinkUrl(item.coverUrl, '?imageView2/3/w/600/format/webp')"
              alt=""
              @click="viewImg(item.moduleId, item.id)"
            />
            <div class="flower-btn">
              <div></div>
            </div>
          </div>
          <p class="items-title" v-if="(index) % 2 !== 0">
            {{ item.name }}
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'style1',
});
</script>

<script setup lang="ts">
import { urls, getLinkUrl } from '@/utils/request/upload';
import { publicUrls } from '@/utils/minxin';
import { DraggableContainer } from 'vue3-draggable-resizable';
// import FlotMenu from '@/components/flotMenu/OutlineMenu.vue';
import ContextMenu from '@imengyu/vue3-context-menu';
import { getDraggableNumber, getExhibitsHeightRest, getdisabledY } from '@/utils/getRemComputed';
import { ref, reactive, watch, nextTick } from 'vue';
import { exbitMenuShow, exbitListMenuShow } from '@/hooks/menuHooks';
import { useProjectStore } from '@/store';
import { defineComponent } from 'vue';

const emit = defineEmits([
  'emitChildItemDraggable',
  'emitChildItemDraggableStyle',
  'emitShowcaseDraggable',
  'emitShowcaseDraggableStyle',
  'onContextMenuChild',
]);
const store = useProjectStore();
const contextMenuTrigger = ref(); //列表盒子dom
const parentLock = ref(true);
const childShow = ref(true);
const draggableResizable = ref(); //父级拖拽盒子ref
const timer = ref();
const ImgVisible = ref(false);
const ImgUrl = ref('');

const props = defineProps({
  width: {
    type: Number || String,
  },
  height: {
    type: Number || String,
  },
  indexs: {
    type: Number,
  },
  info: {
    type: Object,
  },
  childId: {
    type: Number,
  },
  AuxiliaryId: {
    type: Number,
  },
});
const emitChildItemDraggable = (draggingInfo: any, childIndex: number) => {
  emit('emitChildItemDraggable', draggingInfo, childIndex); //分组传递当前展品图距离相对父元素的xy偏移量变化
};
const emitChildItemDraggableStyle = (draggingInfo: any, childIndex: number) => {
  emit('emitChildItemDraggableStyle', draggingInfo, childIndex); //分组设置当前展品图距离相对父元素的宽高变化
};
const emitShowcaseDraggable = (draggingInfo: any) => {
  emit('emitShowcaseDraggable', draggingInfo); //传递当前展柜图距离相对父元素的xy偏移量变化
};
const emitShowcaseDraggableStyle = (draggingInfo: any) => {
  emit('emitShowcaseDraggableStyle', draggingInfo); //传递当前展柜距离相对父元素的宽高变化
};
const getTitle = (name: string) => {
  if (name.length <= 9) {
    return name;
  } else {
    let str = name.slice(0, 8);
    return str + '···';
  }
};
const handleMouseDown = (event) => {
  event.stopPropagation();
};
const preventDefaultDrag = (event) => {
  event.stopPropagation();
};

const viewImg = (moduleId: number, e?: number) => {
  store.exhibitsModuleId = moduleId;
  store.exhibitsShowpieceid = e;
  store.exhibitsInfoShow = true;
};
</script>

<style lang="less" scoped>
.exhibits-content {
  position: relative;
  flex-direction: column;
  display: flex;
  z-index: 999;
  padding: 0px 0.1rem !important;

  -webkit-box-reflect: below 40% linear-gradient(transparent, rgba(0, 0, 0, 0.2));
}
.list {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
}
.item-parent {
  display: flex;
  justify-content: center;
  width: 266px;
  margin-left: 20px;
}

.exhibits-item {
    display: flex;
    flex-direction: column;
    align-items: center;
  position: relative;
  z-index: 66;
  width: 266px;
  height: 558px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.n-mg {  
  margin-left: 0;
}
.items-title {
  writing-mode: vertical-rl;
  text-orientation: mixed; /* 中文常用方式 */
  display: block;
  width:22px;
  height: 195px;
  font-family: SourceHanSerifCN-Bold;
  font-size: 18px;
  color: #623333;
  line-height: 22px;
//   text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cover-box {
  position: relative;
  overflow: hidden;
  width: 246px;
  height: 246px;
  border-radius: 50%;
}
.cover {
  width: 246px;
  height: 246px;
  object-fit: cover;
  transition: all 0.3s;
  border-radius: 50%;
}

.cover-box:hover {
  .cover {
    transform: scale(1.1);
  }
}
.flower-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.3);
  border: 3px solid #ffffff;
  border-radius: 50%;
  div {
    width: 12.5px;
    height: 12.5px;
    background: #ffffff;
    border-radius: 50%;
  }
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 6;
  transform: translate(-50%, -50%);
  animation: flower 2s linear infinite;
  @keyframes flower {
    0% {
      opacity: 0;
    }
    40% {
      opacity: 100%;
    }
    80% {
      opacity: 100%;
    }
    100% {
      opacity: 0;
    }
  }
}
.exhibits-item1 {
  .cover-box {
    margin-top: 30px;
  }
  .items-title {
    margin-top: 39px;
  }
}
.exhibits-item2 {
  .items-title {
    margin-top: 30px;
  }
  .cover-box {
    margin-top: 47px;
  }
}
</style>
